import 'package:flutter_admin/utils/utils.dart';

class QuantWarningLine {

  String? id;
  String? locationId;
  String? locationName;
  String? productTmplId;
  String? productCode;
  String? productName;
  String? productDesc;
  String? quantity;
  String? createUid;
  String? createName;
  String? createDate;
  String? writeUid;
  String? writeDate;

  QuantWarningLine({
    this.id,
    this.locationId,
    this.locationName,
    this.productTmplId,
    this.productCode,
    this.productName,
    this.productDesc,
    this.quantity,
    this.createUid,
    this.createName,
    this.createDate,
    this.writeUid,
    this.writeDate,
  });

  QuantWarningLine copyWith({
    String? id,
    String? locationId,
    String? productTmplId,
    String? quantity,
    String? createUid,
    String? createDate,
    String? writeUid,
    String? writeDate,
  }) {
    return new QuantWarningLine(
      id: id ?? this.id,
      locationId: locationId ?? this.locationId,
      productTmplId: productTmplId ?? this.productTmplId,
      quantity: quantity ?? this.quantity,
      createUid: createUid ?? this.createUid,
      createDate: createDate ?? this.createDate,
      writeUid: writeUid ?? this.writeUid,
      writeDate: writeDate ?? this.writeDate,
    );
  }

  @override
  String toString() {
    return '''QuantWarningLine{
      id: id,
      locationId: locationId,
      productTmplId: productTmplId,
      quantity: quantity,
      createUid: createUid,
      createDate: createDate,
      writeUid: writeUid,
      writeDate: writeDate,
    }''';
  }

  @override
  bool operator ==(Object other) => identical(this, other) || (
      other is QuantWarningLine &&
          runtimeType == other.runtimeType
          && id== other.id
          && locationId== other.locationId
          && productTmplId== other.productTmplId
          && quantity== other.quantity
          && createUid== other.createUid
          && createDate== other.createDate
          && writeUid== other.writeUid
          && writeDate== other.writeDate
   );


  factory QuantWarningLine.fromMap(Map<String, dynamic> map) {
    return new QuantWarningLine(
      id: map['id']!=false?map['id'].toString() as String?:"",
      locationId: map['location_id'][0]!=false?map['location_id'][0].toString() as String?:"",
      locationName: map['location_id'][1]!=false?map['location_id'][1].toString() as String?:"",
      productTmplId: map['product_tmpl_id']["id"]!=false?map['product_tmpl_id']["id"].toString() as String?:"",
      productCode: map['product_tmpl_id']["default_code"]!=false?map['product_tmpl_id']["default_code"].toString() as String?:"",
      productName: map['product_tmpl_id']["name"]!=false?map['product_tmpl_id']["name"].toString() as String?:"",
      productDesc: map['product_tmpl_id']["description"]!=false?map['product_tmpl_id']["description"].toString() as String?:"",
      quantity: map['quantity']!=false?map['quantity'].toString() as String?:"",
      createUid: map['create_uid']!=false?map['create_uid'][0].toString() as String?:"",
      createName: map['create_uid']!=false?map['create_uid'][1].toString() as String?:"",
      createDate: map['create_date']!=false?map['create_date'].toString() as String?:"",
      writeUid: map['write_uid']!=false?map['write_uid'].toString() as String?:"",
      writeDate: map['write_date']!=false?map['write_date'].toString() as String?:"",
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'locationId': this.locationId,
      'productTmplId': this.productTmplId,
      'quantity': this.quantity,
      'createUid': this.createUid,
      'createDate': this.createDate,
      'writeUid': this.writeUid,
      'writeDate': this.writeDate,
    } as Map<String, dynamic>;
  }

  List toDomainList() {
    List list = [
      if(this.locationId!=null&&this.locationId!='')['location_id','=',int.parse(locationId!)],
      if(this.productCode!=null&&this.productCode!='')['product_tmpl_id.default_code','=',this.productCode],
      if(this.productName!=null&&this.productName!='')['product_tmpl_id.name','like','%$productName%'],
    ];
    return list;
  }

  Map<String, dynamic> toOdooMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'location_id': this.locationId,
      'product_tmpl_id': this.productTmplId,
      'quantity': this.quantity,
      'create_uid': this.createUid,
      'create_date': this.createDate,
      'write_uid': this.writeUid,
      'write_date': this.writeDate,
    } as Map<String, dynamic>;
  }

//</editor-fold>

}